
<!-- 弹层 -->
<style type="text/css">
    #link-dialog-category .modal-body .on{
        display: block;
    }
    #link-dialog-balance{
        display: none;
    }
    #link-dialog-point{
        display: none;
    }
    #link-dialog-category div.modal-header{
        border: none;
    }
    #link-dialog-category div.modal-footer{
        border: none;
    }
    .search_btn{
        display: inline-block;
    }
    #search_result_category{
        height: auto;
        overflow: hidden;
    }
    #search_result_category>div{
        margin-bottom: 10px;
        overflow: hidden;
    }
    #search_result_category>div>input{
        float: left;
    }
    #search_result_category>div>input.url{
        width: 75%;
    }
    #search_key{
        overflow: hidden;
        width: 100%;
    }
    #search_key input{
        width: 75%;
        float: left;
    }
    #search_key button{
        float: right;
        margin-left: 20px;
    }
    span.search-result-name{
        width: 80%;
        max-width: 80%;
    }
</style>
<div class="demo">
    <div class="modal fade" id="link-dialog-category" tabindex="-1" role="dialog" aria-hidden="true">
            <div class="modal-dialog">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                        <h4 class="modal-title select_article_btn"><?php echo $this->title?></h4>
                        <ul class="nav nav-tabs" id="tab_title_div">
                        </ul>
                    </div>
                        <div class="modal-body ">

                            <div class="input-group ">
                            </div>
                            <div class="tab-content">
                                <form >
                                    <input type="hidden" id="goods_id" name="goods_id" value=""/>

                                    <div id="link-dialog-balance">
                                        <div class="form-group ship_id_input">
                                            <label>数量</label>
                                            <input class="form-control required" type="text" name="goods[num]" value=""/>
                                        </div>
                                        <div class="form-group">
                                            <label>修改方式</label>
                                            <select class="form-control ship_type_selecter" name="goods[type]">
                                                <option value="1" selected="selected">增加</option>
                                                <option value="2">减少</option>
                                            </select>
                                        </div>
                                    </div>
                                </form>
                            </div>
                        </div>
                        <div class="modal-footer clearfix">
                            <button id="sure-link-dialog sure-link-coupon" type="button" data-dismiss="modal" class="btn btn-primary" onclick="javascript:writeGoodsInfo()">确定</button>
                        </div>
                </div><!-- /.modal-content -->
            </div><!-- /.modal-dialog -->
        </div><!-- /.modal -->
</div>
<!-- 弹层 end-->

<script type="text/javascript" src="/statics/plugins/jquery.tmpl.min.js"></script>

<script type="text/javascript">
// 修改数量
function showLinkDialogForGoodsNum(id){
    var id = id;
    $('#goods_id').val(id);
    $('#link-dialog-category').modal('show');
    $('#link-dialog-balance').show();

}


// 添加修改信息
function writeGoodsInfo(){
    var data = {};
    data['goods_id'] = $("#goods_id").val();
        data['num'] = $("input[name='goods[num]']").val();
        data['type'] = $("select[name='goods[type]']").val();
    if( data['num']==''){
        alert('请填写要修改数量');
        return false;
    }
    $.ajax({
        type:'POST',
        url:'<?php echo $this->getController()->createUrl('/admin/goods/updatenum')?>',
        data: data,
        dataType:'json',
        success:function(re){
            var re_info = eval(re);
            if(re_info>0){
                alert('修改成功');
                location.reload();
            }else{
                alert('修改失败');
            }
        },
        error:function(){
            alert('请求失败');
        }
    });
}
</script>
